package com.luyuan.crm.member.service.impl;

import java.util.List;

import org.hibernate.criterion.Criterion;

import com.luyuan.crm.member.model.Customer;
import com.luyuan.crm.member.service.CustomerService;
import com.ruijie.foundation.dao.support.HibernateEntityDao;

public class CustomerServiceImpl extends HibernateEntityDao<Customer> implements CustomerService {

    @Override
    public Customer getById(String id) {
        return safeGet(id);
    }

    @Override
    public void addCustomer(Customer customer) {
        super.save(customer);
    }

    @Override
    public void updateCustomer(Customer customer) {
        super.update(customer);
    }

    @Override
    public Customer getByMobile(String mobile) {
        return findUniqueBy("mobile", mobile);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<Customer> findBy(Criterion criterion, int size) {
        return createCriteria(criterion).setMaxResults(size).list();
    }
}
